package com.yitiao.data_algorithms.leetcode.editor.cn;

class KLl5u1 {
    // 2023-02-22 16:01:52
    public static void main(String[] args) {
        Solution solution = new KLl5u1().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        int ans[] = new int[2];

        public int[] twoSum(int[] numbers, int target) {
            for (int i = 0; i < numbers.length; i++) {
                int t = target - numbers[i];
                int l = i + 1;
                int r = numbers.length - 1;
                while (l <= r) {
                    int mid = l + (r - l + 1) / 2;
                    if (t < numbers[mid]) {
                        r = mid - 1;
                    } else if (t > numbers[mid]) {
                        l = mid + 1;
                    } else {
                        ans[0] = i;
                        ans[1] = mid;
                        return ans;
                    }
                }
            }
            return ans;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}